import os
import socket


class Client:
    def __init__(self, address: str = '127.0.0.1', port: int = 13249):
        self.address = address
        self.port = port
        os.system(f'adb forward tcp:{self.port} tcp:{self.port}')
        self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    def connect_server(self):
        """
        与服务器进行TCP连接
        """
        self.client.connect((self.address, self.port))

    def client_send(self, data: str) -> str:
        self.client.send(data.encode())
        return self.client.recv(1024).decode()


if __name__ == '__main__':
    client = Client()
    client.connect_server()
    print(client.client_send())
